//package com.bwie.rabbit;
//
//
//import com.bwie.config.DelayedQueueConfig;
//import com.bwie.dao.SeckillDao;
//import com.rabbitmq.client.Channel;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//
//import java.util.Date;
//
//@Controller
//public class Consumer {
//    @Autowired
//    private SeckillDao seckillDao;
//
//
//    private static final String QUEUE_NAME_JIAN =MyQueue.QUEUE_NUM_SUBTRACT;
//    private static final String QUEUE_NAME_JIA =MyQueue.QUEUE_NUM_PLUS;
//    private final Logger log = LoggerFactory.getLogger(Consumer.class);
//
//    @RabbitListener(queues = QUEUE_NAME_JIAN)
//    public void subtractNum(Integer msg, Channel channel){
//        System.out.println("接收到的参数是"+msg);
//        try {
//            int i = seckillDao.updateSubtractNum(msg);
//            if (i>0){
//                System.out.println("修改库存成功");
//            }
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }
//    @RabbitListener(queues = QUEUE_NAME_JIA)
//    public void pulsNum(Integer msg, Channel channel){
//        System.out.println("接收到的参数是"+msg);
//        try {
//            int i = seckillDao.updatePulstNum(msg);
//            if (i>0){
//                System.out.println("修改库存成功");
//            }
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }
//
//    //监听消息
//    @RabbitListener(queues = DelayedQueueConfig.DELAYED_QUEUE_NAME)
//    public void receiverDelayedQueue(Message message){
//        String msg = new String(message.getBody());
//        log.info("当前时间：{}，收到延迟队列的消息：{}",new Date().toString(),msg);
//    }
//}
